<html>
<head>
    <title>[var.TITLE]</title>
    <link href="[var.ROOT_CSS_DIR]/main.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/facet/style.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/thickbox.css" rel="STYLESHEET" type="text/css" media="screen">
    <style type="text/css">
        a.thickbox > img {
            border: none;
            width:  16px;
            height: 16px;
        }
          fieldset {
	        padding: 5px;
	        margin-bottom: 20px;
	    }

	    legend {
	        font-weight: bold;
	        background: #ccc;
	        border: 1px solid #999;
	        padding: 4px;
	    }
    </style>
    <script type="text/javascript" src="[var.ROOT_DIR]js/json2.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/common.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/doiMenuDOM.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js2/jscalendar-1.0/calendar.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js2/jscalendar-1.0/lang/calendar-en.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js2/jscalendar-1.0/calendar-setup.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.php"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.cfg"></script>
	<script type="text/javascript" src="[var.ROOT_DIR]js/jquery.min.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsverify.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsinit.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/thickbox.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions_additem.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="[var.ROOT_DIR]js2/jscalendar-1.0/calendar-win2k-cold-1.css" title="win2k-cold-1">
</head>
<script language="javascript">
var formMode           	= '[var.FormMode]';
var itemsdem 			= [dem.#];
 var _ret = false;
    $(document).ready( function() {

        $("#reqCoa").click(function(e) {
            
        });

		  if ( formMode == 'Edit' ) {
		  		//demurage day is 0
		  		if ( $("#demurage_day_nofree").is(":checked") ) {
                    $("#demurage_day").attr("disabled", true).val('0');
                }
				for (var i = 1;i<=itemscharges;i++){
					if($("#charge_code_"+i).val()=="DEM"){
					$("#percentage_select_"+i).remove();
					$("#percentage_text_"+i).css({'width' : '30px' });
					}//if charge code DEM
					else if($("#charge_code_"+i).val()=="FR"){
						$("#percentage_select_"+i).show();
						$("#percentage_text_"+i).remove();
					}//end else if charge code
					else {
					$("#pre_cal_"+i).hide();
					$("#percentage_select_"+i).remove();
					$("#percentage_text_"+i).remove();
					}
				}//end of for
			}
			 $("#demuragedetention").click(function(e) {
                $target  = $(e.target)
                if ( $target.attr('id') == 'demurage_day_nofree' ) {
                    if ( $target.is(":checked") ) {
                        $("#demurage_day").attr("disabled", true).val('0');
                    } else {
                        $("#demurage_day").attr("disabled", false).val('0');
                    }

                    return true;
                }
            });
            $("#detention").click(function(e) {
                $target  = $(e.target)
                if ( $target.attr('id') == 'detention_day_nofree' ) {
                    if ( $target.is(":checked") ) {
                        $("#detention_day").attr("disabled", true).val('0');
                    } else {
                        $("#detention_day").attr("disabled", false).val('0');
                    }

                    return true;
                }
            });
            $("#search-agent").blur( function(e) {

                if ( $(this).val() == '' ) {
                    $("input[@name=agent_code]").val('');
                    $("input[@name=agent_name]").val('');
                    $("#search-clessor-box").attr("href", "agent_box.php?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=290&width=300");
                    return false;
                }
               $.post("./../tools/agent_xml.php", {agent: $(this).val() }, function(xml) {
                    if ( $("count", xml).text() == '0' ) {
                        alert("Agent Not Found!");
                        $("input[@name=agent_code]").val('');
                        $("input[@name=agent_name]").val('');
                        $("#search-depot-box").attr("href", "agent_box.php?&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=290&width=300");
                    } else if ( $("count", xml).text() == '1' ) {
                        $("input[@name=agent_code]").val( $("code", xml).text() );
                        $("input[@name=agent_name]").val( $("name", xml).text() );

                    } else {
                        var strFilter = "agent_box.php?CodeSearch=" + $("input[@name=agent_code]").val() +
                                        "*&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=290&width=300";
                        $("#search-depot-box").attr("href", strFilter);
                    }
                });
            });
            $("#removeitem2").click(function() {
            	$checkedEl = $("#maincontent2 input[@type=checkbox]").filter(":checked").not("#checkline_all");
            	if ($checkedEl.length > 0) {
            		if (confirm("Are You sure want Delete!!"))
            			$checkedEl.parent().parent().remove();
				}
				else{
					alert("Please Chek the checkbox");
				}
            });
			$("#removeitem3").click(function() {
            	$checkedEl = $("#maincontent3 input[@type=checkbox]").filter(":checked").not("#checkline_all");
            	if ($checkedEl.length > 0) {
            		if (confirm("Are You sure want Delete!!"))
            			$checkedEl.parent().parent().remove();
				}
				else{
					alert("Please Chek the checkbox");
				}
            });
			$("#removeitem4").click(function() {
            	$checkedEl = $("#maincontent4 input[@type=checkbox]").filter(":checked").not("#checkline_all");
            	if ($checkedEl.length > 0) {
            		if (confirm("Are You sure want Delete!!"))
            			$checkedEl.parent().parent().remove();
				}
				else{
					alert("Please Chek the checkbox");
				}
            });
              $("#Add").click( function() {
                var agent_agr_start = $("#agent_agr_start").val();
                var agent_agr_end   = $("#agent_agr_end").val();
                start = agent_agr_start.replace(/[\/]/g,'');
                start = start.substr(4, 4) + start.substr(2, 2) + start.substr(0, 2);
                end   = agent_agr_end.replace(/[\/]/g,'');
                end = end.substr(4, 4) + end.substr(2, 2) + end.substr(0, 2);

                if ( agent_agr_start == '' ) {
                    alert("Value in Start date is required!!");
                    $("#trd_country_det_start")[0].focus();
                    return false;
                }
                if ( agent_agr_end == '' ) {
                    alert("Value in End date is required!!");
                    $("#trd_country_det_end")[0].focus();
                    return false;
                }
                if ( start >= end ) {
		            alert("Value in End date must be higher than value in start date!!");
                    $("#agent_agr_start")[0].focus();
                    return false;
                }

                $.post('agent_agreement_validate.php', {code: $('#search-agent').val(), start: agent_agr_start, end: agent_agr_end}, function(valid) {
                    if (valid == '1') {
                        _ret = true;
                    } else {
                        alert('The start date is still in the range of the last date\nPlease enter start date higher than ' + valid);
                        _ret = false;
                    }
                });
                return _ret;
            });
    });

</script>
<script language="javascript">
    var discrt_type;
    var discrt_amt;
    var tariff;
    var rate_state = '';
    var stat       = '';
    var count_surcharge = '';

    $(document).ready( function() {});

    function update_cont(noitem, cont_code_code, cont_code_desc, cont_type_desc, cont_code_length, cont_code_height, cont_code_oid){
        $("#cont_code_code_div_"+noitem).html( cont_code_code );
        $("#cont_type_desc_div_"+noitem).html( cont_type_desc );
        $("#cont_code_length_div_"+noitem).html( cont_code_length );
        $("#cont_code_height_div_"+noitem).html( cont_code_height );
        $("input[@name=cont_code_code_"+noitem+"]").val( cont_code_code );
        $("input[@name=cont_code_desc_"+noitem+"]").val( cont_code_desc );
        $("input[@name=cont_type_desc_"+noitem+"]").val( cont_type_desc );
        $("input[@name=cont_code_length_"+noitem+"]").val( cont_code_length );
        $("input[@name=cont_code_height_"+noitem+"]").val( cont_code_height );
        $("input[@name=cont_code_oid_"+noitem+"]").val( cont_code_oid );

        updateSelect();
    }

    function update_charge(noitem, charge_code, charge_oid, charge_name){
        $("#charge_code_div_"+noitem).html( charge_code );
        $("input[@name=charge_code_"+noitem+"]").val( charge_code );
        $("input[@name=charge_oid_"+noitem+"]").val( charge_oid );
        $("#charge_name_div_"+noitem).html( charge_name );
    }

    function update_port(port_code, port_name, port_oid, noitem, type){
        $("#port_code_"+type+"_div_"+noitem).html( port_code );
        $("#port_name_"+type+"_div_"+noitem).html( port_name );

        $("#port_oid_"+type+"_"+noitem).val( port_oid );
        $("#port_code_"+type+"_"+noitem).val( port_code );
		period(port_code,noitem,type);
    }

	function period (port_code,noitem,type) {
		$.post("period_xml.php", {port_code: port_code }, function(xml) {
			$("#period_"+type+"_"+noitem).empty();
			$("#period_"+type+"_"+noitem).append("<option value=''>Select Value</option>");
			$("period", xml).each(function(i){
                period_name   = $(this).children("name").text();
                period_oid   = $(this).children("oid").text();
                $("#period_"+type+"_"+noitem).append("<option value='" + period_oid + "'>" + period_name + "</option>");
            });

		});
	}
	function period_days (value,type,noitem) {
		$.post("period_days_xml.php", {period_oid: value }, function(xml) {
                $("#days_"+type+"_div_"+noitem).html($("start", xml).text()+" "+$("symbol", xml).text()+" "+$("end", xml).text());
		});
	}
    function update_clessor(clessor_code, clessor_name){
        $("input[@name=clessor_code]").val(clessor_code);
        $("input[@name=clessor_name]").val(clessor_name);
    }

	 function update_agent(agent_oid, agent_code, agent_name){
        $("input[@name=agent_code]").val(agent_code);
        $("input[@name=agent_name]").val(agent_name);
        $("input[@name=agent_oid]").val(agent_oid);
    }

	function ConvertToUSD(curr_id,local_id,usd_id) {
		
		curr_code 		= $("#"+curr_id).val();
		local_amount 	= $("#"+local_id).val();

		if (curr_code == 'USD') {
			$("#"+usd_id).val(local_amount);
			return false;
		} else {
			$.post("../cont-tracking/get_cost_repo.php", {currency_code: curr_code, value: local_amount}, function(xml) {
				$("#"+usd_id).val($("usd", xml).text());
			});
			return false;	
		}
	}
    var itemscharges = [dem.#];
    var dataLength_ = new Array();
    var valueLength_ = new Array();

</script>

<body bgcolor="FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" align="[var.POSITION]">
        <tr>
            <td>[tbs_include.onshow;file=[var.HTMLHeader];getob;]</td>
        </tr>
        <tr>
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>

                <tr>
                    <td background="[var.ROOT_IMG_DIR]/back-menu.gif">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <tr>
                            <td>
                            <script language="JavaScript" type="text/JavaScript">menu.Build();</script>
                          </td>
                              <td class="head-login">Login as [var.USERPROFILE_NAME]</td>
                        </tr>
                      </table>
                    </td>
                </tr>

                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
            </table>
            </td>
        </tr>
        <tr height="100%">
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                <tr valign="top">
                    <td width="100%">
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tr>
                                <td class="head-path"></td>
                                <td class="corner-date">[var.CORNER_DATE]</td>
                            </tr>
                        </table>

                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="FacetHeaderContent" >.:[var.SubHeaderTitle]:.</td>
                            </tr>
                        </table>

                        <table border="a" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="contentTitle">
                                Menu
                                </td>
                            </tr>

                            <tr>
                                <td class="content2">
                                <table cellspacing="2" cellpadding="0">
                                 <tr>
                                   <td>
                                    <input type="button" name="Action" value="<<Back" class="button" onClick="self.location.replace('[sys.script_name]')">
                                   </td>

                                   <td>
                                     <input type="button" name="Action" value="Done" class="button" onClick="self.location.replace('[var.FileName]')">
                                   </td>
                                 </tr>
                                </table>
                                </td>
                            </tr>

                            <tr>
                                <td class="content2">
                                <!-- FORM SECTION -->
                                <form method="post" action="[var.FormAction;htmlconv=no]"
                                      name="[var.HTMLFormName]">
                                      <fieldset>
										<table border="0" cellspacing="2" cellpadding="0" width="auto">
                                                <tr>
                                                    <td>[tbs_check;block=td;if [var.listTariff;noerr]=1]
                                                        <fieldset>
                                                        <legend>List Tariff in [var.depoName;noerr]</legend>
                                                        <table width="100%" class="FacetFormTABLE">
                                                        <tr>
                                                            <td nowrap class="FacetCaption" colspan="5"></td>
                                                        </tr>
                                                        <tr>
                                                            <td nowrap class="FacetColumnTD">No</td>
                                                            <td nowrap class="FacetColumnTD">Tariff Name</td>
                                                            <td nowrap class="FacetColumnTD">Date Start</td>
                                                            <td nowrap class="FacetColumnTD">Date End</td>
                                                            <td nowrap class="FacetColumnTD">Container Size</td>
                                                        </tr>
                                                        <tr>
                                                            <td nowrap class="FacetColumnTD">[atas.#;block=tr;noerr]</td>
                                                            <td nowrap class="FacetColumnTD"><a href="[var.FileName]?tbldepo_id=[atas.tbldepo_id]&id=[atas.id;noerr]&PageMode=Form">[atas.name;noerr]</a></td>
                                                            <td nowrap class="FacetColumnTD">[atas.start_date;noerr;frm='dd/mm/yyyy']</td>
                                                            <td nowrap class="FacetColumnTD">[atas.end_date;noerr;frm='dd/mm/yyyy']</td>
                                                            <td nowrap class="FacetColumnTD" align="center">[atas.container_size;noerr]</td>
                                                        </tr>
                                                        </table>
                                                        </fieldset>
                                                                                                        
                                                    </td>
                                                </tr>
                                                
												<tr>
													<td colspan="2" style="vertical-align: top">
													<fieldset>
													<legend>Header</legend>
													<table>
													    <tr>
													        <td class="fieldCaption" align="right">Tariff Name : </td>
																<td>
                                                                    <input type="text" id="tariffName" name="tariffName" value="[tbs_check;if [var.FormMode]=Edit; then '[hd.name;noerr]'; else '']" maxlength="25" size="25" class="input" />
																</td>
															</tr>
													    <tr>
													        <td class="fieldCaption" align="right">Depo Name : </td>
																<td>
                                                                    <select name="depoName" class="input">
                                                                    <option value="">-</option>
                                                                    <option value="[depotMaster.id]">[depotMaster.name;block=option]</option>
                                                                    <option>[tbs_check;if [var.FormMode]=Edit; then '[hd.depoName;selected;noerr]'; else '']</option>
                                                                    </select>
																</td>
															</tr>
															<tr>
																<td class="fieldCaption" align="right">Container Size : </td>
																<td>
                                                                    <select name="contSize" class="input">
                                                                    <option value="">-</option>
                                                                    <option value="[containerSize.key]">[containerSize.val;block=option]</option>
                                                                    <option>[tbs_check;if [var.FormMode]=Edit; then '[hd.container_size;selected;noerr]'; else '']</option>
                                                                    </select>
																</td>
															</tr>
                                                            <tr>
                                                                <td class="fieldCaption" align="right">Start Date :</td>
                                                                <td class="fieldCaption">
                                                                    <input type="text" id="start_date" name="start_date" value="[tbs_check;if [var.FormMode]=Edit; then '[hd.start_date;noerr; frm='dd/mm/yyyy']'; else [sys.now;frm='dd/mm/yyyy']]" maxlength="25" size="10" class="input">
                                                                    <image id="start_date_button" src="[var.ROOT_DIR]images/calendar2.gif" border=0 />
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td class="fieldCaption" align="right">End Date :</td>
                                                                <td class="fieldCaption">
                                                                    <input type="text" id="end_date" name="end_date" value="[tbs_check;if [var.FormMode]=Edit; then '[hd.end_date;noerr; frm='dd/mm/yyyy']'; else [sys.now;frm='dd/mm/yyyy']]" maxlength="25" size="10" class="input" />
                                                                    <image id="end_date_button" src="[var.ROOT_DIR]images/calendar2.gif" border=0 />
                                                                </td>
                                                            </tr>                                                            
													</table>
													</fieldset>
													</td>
												</tr>
										</table>
									<!--Demurage -->
									<fieldset>
                                    <legend>Detail</legend>
                                    <table border="0" width="95%" cellpadding="0" cellspacing="1" class="FacetFormTABLE" align="left" id="tableDemurage">
                                    <tbody id="maincontent3">
		                                <tr>
		                                    <td class="fieldCaption" colspan="9">&nbsp;</td>
		                                </tr>
										<tr>
		                                    <td nowrap class="FacetColumnTD" align="center" width="2%">
		                                        <input type="checkbox" name="checkline_all" id="checkline_all" onclick="javascript:checkAllByPrefix(itemscharges, this, 'checkline_')">
		                                    </td>

		                                    <td nowrap class="FacetColumnTD" align="center">Item Name</td>
		                                    <td nowrap class="FacetColumnTD" align="center">COA</td>
		                                    <td nowrap class="FacetColumnTD" align="center">Rate / Amount</td>
                                    	</tr>
										<tr id="row3_[dem.#]">
		                                    <td nowrap class="FacetColumnTD" align="center" width="2%">
		                                        <input type="checkbox" name="checkline_dem_[dem.#]" id="checkline_dem_[dem.#;block=tr]" onclick="">
		                                    </td>
											<td nowrap class="FacetColumnTD" align="center">
												<select name="detail_item_[dem.#]" id="detail_item_[dem.#]" class="input" >
													<option value="">Select Value</option>
													<option value="[receipt.kdreceipt]">[receipt.receiptname;block=option]</option>                                                   
													<option>[dem.receiptname;selected;noerr]</option>
												</select>   
		                                    </td>
											<td nowrap class="FacetColumnTD" align="center">
												<input name="coa_[dem.#]" id="coa_[dem.#]" size="20" class="input" style="text-align:center" value="[dem.coa;noerr]">
                                        	</td>	
											<td nowrap class="FacetColumnTD" align="center">
		                                   		<input name="rate_[dem.#]" id="rate_[dem.#]" size="20" class="input" style="text-align:right" value="[dem.rate;noerr]">
										</tr>
										<tr id="lastborder3"></tr>
                                    	</tbody>
									</table>								
									<table border="0" width="95%">
                                        <tr>
                                            <td nowrap width="8%" align="left" >[tbs_check;block=td;if [var.USER_CANDELETE]=1]
                                                <input type="button" value="Remove Selected Item" name="removeitem3" id="removeitem3" class="button" />
                                            </td>
                                            <td align="left">[tbs_check;block=td;if [var.USER_CANINSERT]=1]
                                                <input type="button" value="Add Item" name="additem3" id="additem3"
                                                       class="button" onclick="javascript:if(checkLineDemDet('dem')){ AddItem3(); }" >
                                            </td>
                                            <input type="hidden" name="numitems3" id="numitems3" value="[dem.#]"/>
                                        </tr>
                                    </table>
									</fieldset>

                                    <script type="text/javascript">
 								
									function AddItem3() {
									/** Function Add Demurage **/
                                        updateSelect();
                                        var div = $("#maincontent3")[0];
                                        var lastborder = $("#lastborder3")[0];
                                        var num = $("#numitems3")[0];
                                        if((num.value*1)==0){
                                            itemscharges = 1;
                                        } else {
                                            itemscharges = (num.value*1);
                                        }
                                        itemscharges++;
                                        num.value = itemscharges;
                                        tr1 = document.createElement("tr");
                                        td1 = makeTdCheck('checkline_dem_'+itemscharges, 'checkline_dem_'+itemscharges, '', "center");
                                        tr1.appendChild(td1);

										var dataItem_ = new Array('Select Value',[var.stringValue;htmlconv=no]);
                                        var valueItem_ = new Array('0',[var.stringItem;htmlconv=no]);
                                        td1 = makeTdSelect('detail_item_'+itemscharges, 'detail_item_'+itemscharges, dataItem_, valueItem_, 'center');
                                        tr1.appendChild(td1);										

										td1 = makeTdInput('text','coa_'+itemscharges,'coa_'+itemscharges,'', 20, 255, 'center','text-align:right');
                                        tr1.appendChild(td1);
                                        
                                        td1 = makeTdInput('text','rate_'+itemscharges,'rate_'+itemscharges,'', 20, 255, 'center','text-align:right');
                                        tr1.appendChild(td1);

                                        tr1.setAttribute('id', "row3_"+itemscharges);
                                        div.insertBefore(tr1, lastborder);
                                    } // end : function AddItem()

                                   </script>
                                    <table border="0" cellspacing="2" cellpadding="0">
                                                <tr>
                                                    <td>[tbs_check;block=td;if [var.FormMode]=Add][tbs_check;block=td;if [var.USER_CANINSERT]=1]
                                                        <input name="Action" id="Add" type="submit"
                                                               value="Add" class="button">
                                                    </td>
                                                    <td>[tbs_check;block=td;if [var.FormMode]=Edit][tbs_check;block=td;if [var.USER_CANUPDATE]=1]
                                                        <input name="Action" id="Update" type="submit"
                                                               value="Update" class="button">
                                                    </td>
                                                    <td>[tbs_check;block=td;if [var.FormMode]=Edit][tbs_check;block=td;if [var.USER_CANDELETE]=1]
                                                    <input type="Submit" name="Action" id="Action"
                                                           value="Delete" class="button"
                                                           onClick="if (confirm('Are you sure want to delete Agent Agreeement for Agreement No : [blv.agent_agr_code;noerr]?')) {return true;}else{ return false; }">                                
                                                    </td>
                                                    <td>
                                                    <input name="Action" id="Action" type="submit" value="Cancel" class="button">
                                                    </td>
                                                </tr>
                                            </table>
                                </td>
                            </tr>

                        </table>
                        </fieldset>
                        </form>
                        <!-- FORM SECTION -->

                   </td>
                </tr>
            </table>
            </td>
        </tr>
        <tr>
            <td>
            <br />
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="footer1"><img src="images/spacer.gif" height="1" width="1"></td>
                    [tbs_include.onshow;file=[var.HTMLFooter];getob;]
                </tr>
            </table>
            </td>
        </tr>
    </table>
    <script language="javascript">
    Calendar.setup(
        {
          inputField  : "start_date",
          ifFormat    : "%d/%m/%Y",
          showsTime   : false,
          timeFormat  : "24",
          button      : "start_date_button"
        }
      );
    Calendar.setup(
        {
          inputField  : "end_date",
          ifFormat    : "%d/%m/%Y",
          showsTime   : false,
          timeFormat  : "24",
          button      : "end_date_button"
        }
      );

	function checkLineDemDet(type){
        var flagCont = true;
        var msg = '';
        var items = $('#numitems3').val();

        for(var x=1; x<=items; x++){
            if($('#detail_item_'+x)[0] && (($('#detail_item_'+x).val() * 1) == 0)) {
               msg = msg + "Value in ITEM on line "+ x +" is required!!\n";
               flagCont = false;
            }

            if($('#rate_'+x)[0] && ($('#rate_'+x).val()  == "")) {
               msg = msg + "Value in RATE on line "+ x +" is required!!\n";
               flagCont = false;
            }
        }
        if(flagCont==false){
            alert(msg);
        }
        return flagCont;
    }
    function formCheck(){
        var formChekx = false;

        formCheckx = [tbs_check;if [var.Verification]='Enable';then 'VerifyForm(this.form)'; else 'true'];
        if(formCheckx){
            formCheckx = checkLineCont();
        }

        if(formCheckx){
            formCheckx = checkLineChrg();
        }

        return formCheckx;
    }

    function updateSelect(){
        dataLength_ = new Array('Select Value');
        valueLength_ = new Array('');

        var datadb2 = new Object();
        datadb2[0] = [{value:'', text:'Select Value'}];
        var dtSlc = new Array();
        var z = 0;

        for(var x=1; x<=itemscharges; x++){
            if($('#container_length_'+x)[0]){
                prevVal = $('#container_length_'+x).val();
                setSelect($('#container_length_'+x)[0], datadb2, 0);
                $('#container_length_'+x).val(prevVal);
            }
        }
    }

    function setSelect(selectChooser, datadb, id) {
        var newElem;
        var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;

        while (selectChooser.options.length) {
            selectChooser.remove(0);
        }
        var db = datadb[id];
        newElem = document.createElement("option");
        for (var i = 0; i < db.length; i++) {
            newElem = document.createElement("option");
            newElem.text = db[i].text;
            newElem.value = db[i].value;
            selectChooser.add(newElem, where);
        }
    }

    updateSelect();
    var d = $('#numitems2').val();
    for(var y=1;y<=d;y++){
        if($('#dtLengthHeight_'+y)){
            var v = $('#dtLengthHeight_'+y).val();
            $('#container_length_'+y).val(v);
        }
    }
    </script>
    </body>
</html>

